from BasePage import BasePage
import time


class LoginPage(BasePage):
    _denglu = (BasePage.ID, 'com.zoneyet.gaga:id/tv_Login')
    _zhanghaodenglu = (BasePage.ID, 'com.zoneyet.gaga:id/tv_login_pwd')
    _clearBtn = (BasePage.ID, 'com.zoneyet.gaga:id/iv_clear')
# _username = (BasePage.XPATH, '''
# /hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout
# /android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout/android.view.ViewGroup
# /android.widget.LinearLayout[1]/android.widget.LinearLayout/android.widget.EditText''')
# _username = (BasePage.XPATH, "输入手机号码/邮箱/Gaga ID")android.widget.EditText
    _username = (BasePage.XPATH, "//android.widget.EditText[@text='输入手机号码/邮箱/Gaga ID']")
    _password = (BasePage.XPATH, '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout/android.view.ViewGroup/android.widget.LinearLayout[2]/android.widget.LinearLayout/android.widget.EditText')
    _xieyi = (BasePage.ID, "com.zoneyet.gaga:id/iv_use_agreement")
    _loginButton = (BasePage.ID, "com.zoneyet.gaga:id/btn_login")
    _qqBtn = (BasePage.ID, "com.zoneyet.gaga:id/iv_qq")
    _qqShow = (BasePage.ID, "com.tencent.mobileqq:id/fds")
    _owerBtn = (BasePage.XPATH, "android.widget.TextView[@text='Me']")
    _woBtn = (BasePage.XPATH, "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout[2]/android.widget.FrameLayout[4]/android.widget.RelativeLayout/android.widget.ImageView")
    _exitBtn = (BasePage.ID, "com.zoneyet.gaga:id/set_exit")
    _okBtn = (BasePage.ID, "com.zoneyet.gaga:id/ok")
    _shezhiBtn = (BasePage.ID, "com.zoneyet.gaga:id/iv_setting")
    _wbBtn = (BasePage.ID, "com.zoneyet.gaga:id/iv_sina")
    _wxBtn = (BasePage.ID, "com.zoneyet.gaga:id/iv_weixin")
    _wxAgree = (BasePage.ID, "com.tencent.mm:id/err")

    def account_login(self, username, password):
        self.click(self._denglu)
        self.click(self._zhanghaodenglu)
        # self.click(self._clearBtn)
        # self.send_keys(self._username, username)
        self.send_keys(self._username, username)
        self.send_keys(self._password, password)
        self.click(self._xieyi)
        self.click(self._loginButton)

    def qq_login(self):
        self.click(self._denglu)
        self.click(self._xieyi)
        self.click(self._qqBtn)
        self.click(self._qqShow)

    def sign_out(self):
        self.click(self._woBtn)
        self.click(self._shezhiBtn)
        time.sleep(3)
        self.swipe_up()
        self.click(self._exitBtn)
        self.click(self._okBtn)

    def wb_login(self):
        self.click(self._denglu)
        self.click(self._xieyi)
        self.click(self._wbBtn)

    def wx_login(self):
        self.click(self._denglu)
        self.click(self._xieyi)
        self.click(self._wxBtn)
        self.click(self._wxAgree)

